package com.suyang.syt.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.suyang.syt.model.dto.AjaxObj;
import com.suyang.syt.service.interfaces.BannerService;
import com.suyang.syt.util.AppUtil;
import com.suyang.syt.util.EmptyUtil;
import com.suyang.syt.util.StringUtil;

@Controller
@RequestMapping("/banner")
public class AppBannerController {

	@Autowired
	private BannerService bannerService;

	@RequestMapping(value = "/findPic", method = RequestMethod.POST)
	@ResponseBody
	public AjaxObj findPic(HttpServletRequest request, String cityid) {
		try {
			String msg = AppUtil.validateSn(request);
			if ("验证成功".equals(msg)) {
				long cid = 3;
				if (EmptyUtil.isNotEmpty(cityid)) {
					cid = Long.parseLong(cityid);
				}
				return bannerService.findPic(cid);
			} else {
				return new AjaxObj(0, msg);
			}
		} catch (Exception e) {
			return new AjaxObj(0, StringUtil.ERROR_MSG);
		}
	}

}
